package eu.szemraj.utils.platform {
    
    import flash.system.Capabilities;   

    public class PlatformUtil {


        public static function getPlayerVersion():PlayerVersion {
   		
            var versionString:String = Capabilities.version;
            var pattern:RegExp = /^(\w*) (\d*),(\d*),(\d*),(\d*)$/;
            var result:Object = pattern.exec( versionString );
   		
            var pv:PlayerVersion = new PlayerVersion( );
            pv.platform = result[1];
            pv.majorVerison = int( result[2] );
            pv.minorVersion = int( result[3] );
            pv.buildNumber = int( result[4] );
            pv.internalBuildNumber = int( result[5] );
         
            return pv; 
        }

        public static function getPlayerType():PlayerType {
      	
            var pt:PlayerType;
            switch( Capabilities.playerType ) {
      		
                case "StandAlone" : 
                    pt = PlayerType.PROJECTOR;
                    break;
                case "Desktop" : 
                    pt = PlayerType.AIR;
                    break;
                case "ActiveX" : 
                    pt = PlayerType.ACTIVEX;
                    break;
                case "PlugIn" : 
                    pt = PlayerType.PLUGIN;
                    break; 	
                case "External" :
                    pt = PlayerType.EXTERNAL;
                    break;
            }
            return pt;
        }

        public static function get inBrowser():Boolean {
      	
            return getPlayerType( ).isInBrowser( );
        }

    }
}
